#原方法
# list=[]
# for i in range(1,11):
#     list.append(i)
#
# print(list)
#

# 列表推导式
# 语法
# list =[表达式+for +变量+in+列表] #表达式是对for循环的操作
# list1 =[i for i in range(1,11)]
# print(list1)
#
# #求立方
# list2 =[i**3 for i in range(1,11)]
# print(list2)
#
# #拼接
# list3 =['hello'+str(i) for i in range(1,11)]
# print(list3)
# # 求奇数100以内
# list4 =[i for i in range(1,101,2)]
# print(list4)

# list5 =[i for i in range(1,101,2) if i%2!=0]
lista =[i for i in range(1,100)]
print(lista)
#
# for i in range(0,len(lista),3):
#     # print(i)
#     print(lista[i:i+3])


list6=[lista[i:i+3] for i in range(0,len(lista),3)]
print(list6)

#
# 需求:有一个list_demo=['abc','xyz','aab','vab'] 用列表推导式找出a开头的字符
# list_demo=['abc','xyz','aab','vab']
# listb =[i for i in list_demo if i.startswith('a')==True]
# print(listb)